﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>明细表属性</title>
    <link href="../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../Comm/Style/Table0.css" rel="stylesheet" type="text/css" />
    <link href="../../Comm/Style/Tabs.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="../../Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="../../Scripts/easyUI145/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="../../Scripts/QueryString.js" type="text/javascript"></script>

    <script src="../../Scripts/EasyUIUtility.js" type="text/javascript"></script>
    <script src="../../Scripts/config.js" type="text/javascript"></script>
	<script src="../../Comm/Gener.js" type="text/javascript"></script>

    <base target="_self" />
      <script type="text/javascript">

		closeWhileEscUp();

        //页面启动函数.
		$(function () {

		    $("#Msg").html("<img src=../../Img/loading.gif />&nbsp;正在加载,请稍后......");

		    //公共变量.
		    //表单ID.
		    var fk_mapData = GetQueryString("FK_MapData");
		    //明细表ID.
		    var fk_mapDtl = GetQueryString("FK_MapDtl");

		    var attrs = new Entities("BP.Sys.MapAttrs");
		    attrs.Retrieve("FK_MapData", fk_mapDtl, "Idx");

		    $("#trTitle").append("<th>序</th>");

		    var colNum = 0;
		    //生成表头..
		    for (var i = 0; i < attrs.length; i++) {

		        var attr = attrs[i];
		        var visable = attr.UIVisible;
		        if (visable == 0)
		            continue;


		        colNum++;

		        var mypk = attr.MyPK;
		        var dataType = attr.MyDataType;
		        var field = attr.KeyOfEn;
		        var name = attr.Name;
		        var lgType = attr.LGType;
		        var uiBindKey = attr.UIBindKey;
		        var uiContralType = attr.UIContralType; //控件类型.
		        var uiWidth = attr.UIWidth; //宽度.

		        var nameLink = "";
		        if (lgType == 0) {
		            nameLink = "<a href=\"javascript:Edit('" + mypk + "','" + dataType + "')\" > " + name + "</a>";
		        }

		        if (lgType == 1) {
		            nameLink = "<a href=\"javascript:EditEnumForDtl('" + fk_mapDtl + "','" + mypk + "','" + uiBindKey + "')\" > " + name + "</a>";
		        }

		        if (lgType == 2) {
		            nameLink = "<a href=\"javascript:EditTable('" + fk_mapDtl + "','" + mypk + "','" + uiBindKey + "')\" > " + name + "</a>";
		        }

		        var col = "";
		        if (dataType == 2 || dataType == 3 || dataType == 5 || dataType == 6 || dataType == 8)
		            col = "<th style='word-break: keep-all;' nowarp=true ><a href=\"javascript:Up('" + mypk + "');\" ><img src='../../../WF/Img/Btn/Left.gif' /></a>" + nameLink + "<a href=\"javascript:Down('" + mypk + "')\" ><img src='../../../WF/Img/Btn/Right.gif' /></a></th>";
		        else
		            col = "<th style='width:" + uiWidth + "px;word-break: keep-all;' nowarp=true ><a href=\"javascript:Up('" + mypk + "');\" ><img src='../../../WF/Img/Btn/Left.gif' /></a>" + nameLink + "<a href=\"javascript:Down('" + mypk + "')\" ><img src='../../../WF/Img/Btn/Right.gif' /></a></th>";

		        $("#trTitle").append(col);
		    }

		    var mapDtl = new Entity("BP.Sys.MapDtl");
            mapDtl.No=fk_mapDtl;
            mapDtl.RetrieveFromDBSources();


		    if (mapDtl.IsEnableAthM==1 ) {
		        $("#trTitle").append("<th>附件</th>");
		    }


		    $("#trTitle").append("<th>操作</th>");

		    //  $("#trTitle").append("</tr>");


		    //生成内容行.
		    for (var idx = 0; idx < 6; idx++) {

		        var newRow = "<tr>";

		        newRow += "<td class=Idx >" + idx + "</td>";
		        for (var i = 0; i < attrs.length; i++) {

		            var attr = attrs[i];

		            var visable = attr.UIVisible;
		            if (visable == 0)
		                continue;

		            var mypk = attr.MyPK;
		            var dataType = attr.MyDataType;
		            var field = attr.KeyOfEn;
		            var name = attr.Name;
		            var lgType = attr.LGType;
		            var uiBindKey = attr.UIBindKey;
		            var uiContralType = attr.UIContralType; //控件类型.
		            var uiWidth = attr.UIWidth; //宽度.
		            var defVal = attr.DefVal; //默认值.

		            if (defVal == "null" || defVal == null)
		                defVal = "";

		            var td = "";
		            td = "<td >" + defVal + "</td>";

		            //doubble, float 类型.
		            if (dataType == 3 || dataType == 5 || dataType == 2)
		                td = "<td style='text-align:right'  >" + defVal + "</td>";

		            //money 类型.
		            if (dataType == 8)
		                td = "<td style='text-align:right' >" + defVal + "</td>";

		            //日期类型.
		            if (dataType == 6) {
		                td = "<td >yyyy-MM-dd</td>";
		            }

		            //日期时间类型.
		            if (dataType == 7) {
		                td = "<td >yyyy-MM-dd HH:mm</td>";
		            }

		            if (dataType == 4) {
		                td = "<td ><input type=checkbox value='1' id=" + field + "_" + i + " />" + name + "</td>";
		            }


		            if (uiContralType == 1)
		                td = "<td >[下拉框]</td>";

		            newRow += td;
		        }

		        if (mapDtl.IsEnableAthM==1) {
		            var opt = "";
		            opt += "<a href=\"javascript:alert('1.点击可以上传附件.\t\r 2.附件权限控制在从表属性里设置.')\" >上传</a>";
		            newRow += "<td>" + opt + "</td>";
		        }

		        newRow += "<td></td>";

		        newRow += "</tr>";
		        $("#dtlTable tr:last").after(newRow);
		    }

		    $("#Msg").html("");

		});


          function AddF(fk_mapdata) {

              var url = 'FieldTypeList.htm?FK_MapData=' + fk_mapdata;
              OpenEasyUiDialog(url, "eudlgframe", '新增字段', 800, 500, "icon-property", true, null, null, null, function () {
                  window.location.href = window.location.href;

              });

              //  var b = window.showModalDialog(url, 'ass', 'dialogHeight: 500px; dialogWidth: 600px;center: yes; help: no');
              //window.location.href = window.location.href;
          }
        function AddFGroup(fk_mapdata) {
            var url = 'Do.aspx?DoType=AddFGroup&FK_MapData=' + fk_mapdata;
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 500px; dialogWidth: 600px;center: yes; help: no');
            window.location.href = window.location.href;
        }
        function CopyF(fk_mapdata) {
            var url = 'CopyDtlField.htm?FK_MapData=' + fk_mapdata + '&s=' + Math.random();
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 600px; dialogWidth: 800px;center: yes; help: no');
            window.location.href = window.location.href;
        }

        function HidAttr(mypk) {
            var url = 'HidAttr.htm?FK_MapData=' + mypk + '&s=' + Math.random();
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 600px; dialogWidth: 800px;center: yes; help: no');
            //  window.location.href = window.location.href;
        }
        function Edit(mypk, ftype) {
            var parentwin = parent.window;
            if (parentwin) {

                var iFrame = parentwin.document.getElementById("F");
                if (iFrame && iFrame.contentWindow && iFrame.contentWindow.location.href == location.href) {
                    parentwin.Edit(mypk, ftype);
                    return;
                }
                parentwin.Edit(mypk, ftype);
                //alert("err");
                return;
            }

            var url = '';
            var title = ''

            //普通字段类型.
            if (ftype == "1") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrString&inlayer=1&PKVal=" + mypk;
                title = '字段String属性';
            }

            //数值字段类型.
            if (ftype == "2") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Int属性';
            }

            //数值字段类型.
            if (ftype == "3") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Float属性';
            }

            //数值字段类型.
            if (ftype == "5") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Double属性';
            }

            //数值字段类型.
            if (ftype == "8") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrNum&inlayer=1&PKVal=" + mypk;
                title = '字段Moeny属性';
            }


            //日期类型date.
            if (ftype == "6") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrDT&inlayer=1&PKVal=" + mypk;
                title = '字段Date属性';

            }

            //日期类型datetime.
            if (ftype == "7") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrDT&inlayer=1&PKVal=" + mypk;
                title = '字段DateTime属性';
            }

            // boolen 类型.
            if (ftype == "4") {
                url = "../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrBoolen&inlayer=1&PKVal=" + mypk;
                title = '字段Boolen属性';
            }

            if (url == '') {
                alert('@没有判断的类型' + ftype);
                return;
            }
            
            OpenEasyUiDialog(url, "eudlgframe", title, 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }

        function EditEnumForDtl(fk_mapdata, mypk, enumKey) {

            var parentwin = parent.window;
            if (parentwin) {
                var iFrame = parentwin.document.getElementById("F");

                if (iFrame && iFrame.contentWindow && iFrame.contentWindow.location.href == location.href) {
                    parentwin.EditEnum(fk_mapdata, mypk, enumKey);
                    return;
                }
                parentwin.EditEnum(fk_mapdata, mypk, enumKey);
                return;
            }

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrEnum&inlayer=1&PKVal=' + mypk + '&s=' + Math.random();

            OpenEasyUiDialog(url, "eudlgframe", "编辑枚举字段", 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });
        }
        function EditTable(fk_mapdata, mypk, fk_sfTable) {

            var parentwin = parent.window;

            if (parentwin) {

                var iFrame = parentwin.document.getElementById("F");


                if (iFrame && iFrame.contentWindow && iFrame.contentWindow.location.href == location.href) {
                    parentwin.EditTable(fk_mapdata, mypk, fk_sfTable);
                    return;
                }

                parentwin.EditTable(fk_sfTable, mypk, fk_mapdata);
                return;
            }

            var url = '../../Comm/En.htm?EnName=BP.Sys.FrmUI.MapAttrSFTable&inlayer=1&PKVal=' + mypk + '&s=' + Math.random();

            OpenEasyUiDialog(url, "eudlgframe", "外键字段属性", 800, 500, "icon-edit", true, null, null, null, function () {
                window.location.href = window.location.href;
            });

        }

        function closeDlg() {
            $("#eudlg").dialog("close");
        }

        function Up(mypk) {

            var en = new Entity("BP.Sys.MapAttr", mypk);
            var data = en.DoMethodReturnString("DoUpForMapDtl");
            if (data.indexOf('err@') != -1)
                alert(data);

            window.location.href = window.location.href;
        }
        function Down(mypk) {

            var en = new Entity("BP.Sys.MapAttr", mypk);
            var data = en.DoMethodReturnString("DoDownForMapDtl");
            if (data.indexOf('err@') != -1)
                alert(data);

            window.location.href = window.location.href;
        }

         
        function Del(fk_mapdata, refNo) {
            if (window.confirm('您确定要删除吗？') == false)
                return;

            var url = 'Do.aspx?DoType=Del&MyPK=' + fk_mapdata + '&RefNo=' + refNo;
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 400px; dialogWidth: 600px;center: yes; help: no');
            window.location.href = window.location.href;
        }
        function DtlMTR(MyPK) {
            var url = 'MapDtlMTR.aspx?MyPK=' + MyPK + '&s=' + Math.random();
            var b = window.showModalDialog(url, 'ass', 'dialogHeight: 350px; dialogWidth: 550px;center: yes; help: no');
            window.location.href = window.location.href;
        }
        
        function Attachment(fk_mapdtl) {
            var url = 'Ath.htm?IsBTitle=1&PKVal=0&FK_MapData=' + fk_mapdtl + '&FK_FrmAttachment=' + fk_mapdtl + '_AthMDtl&Ath=AthMDtl&s=' + Math.random();
            window.showModalDialog(url, 'xx','dialogWidth=750px;dialogHeight=700px');
        }
       
      </script>
</head>
<body>
<table id='dtlTable' >
<tr id='trTitle'>
</tr>

</table>


</body>
</html>
